/*
 * 2021.03.27-Code rectification and function enhancement.
 *            Huawei Device Co., Ltd. <mobile@huawei.com>
 */

#ifndef __UIEDIT_H__
#define __UIEDIT_H__

#pragma once

namespace DuiLib {
class CEditWnd;

class UILIB_API CEditUI : public CLabelUI {
    DECLARE_DUICONTROL(CEditUI)
    friend class CEditWnd;

public:
    ~CEditUI();
    CEditUI();

    void StartEdit();
    void StopEdit();

    LPCTSTR GetClass() const;
    LPVOID GetInterface(LPCTSTR pstrName);
    UINT GetControlFlags() const;

    void SetEnabled(bool bEnable = true) override;
    void SetText(LPCTSTR pstrText);
    void SetMaxChar(UINT uMax);
    UINT GetMaxChar();
    void SetReadOnly(bool bReadOnly);
    bool IsReadOnly() const;
    void SetPasswordMode(bool bPasswordMode);
    bool IsPasswordMode() const;
    void SetPasswordChar(TCHAR cPasswordChar);
    TCHAR GetPasswordChar() const;
    void SetNumberOnly(bool bNumberOnly);
    bool IsNumberOnly() const;
    UINT GetWindowStyls() const;

    LPCTSTR GetNormalImage();
    void SetNormalImage(LPCTSTR pStrImage);
    LPCTSTR GetHotImage();
    void SetHotImage(LPCTSTR pStrImage);
    LPCTSTR GetFocusedImage();
    void SetFocusedImage(LPCTSTR pStrImage);
    LPCTSTR GetDisabledImage();
    void SetDisabledImage(LPCTSTR pStrImage);
    void SetNativeEditBkColor(DWORD dwBkColor);
    DWORD GetNativeEditBkColor() const;
    void SetNativeEditTextColor(LPCTSTR pStrColor);
    DWORD GetNativeEditTextColor() const;

    void SetSel(long nStartChar, long nEndChar);
    void SetSelAll();
    void SetReplaceSel(LPCTSTR lpszReplace);

    void SetTipValue(LPCTSTR pStrTipValue);
    LPCTSTR GetTipValue();
    void SetTipValueColor(LPCTSTR pStrColor);
    DWORD GetTipValueColor();

    void SetPos(RECT rc, bool bNeedInvalidate = true);
    void Move(SIZE szOffset, bool bNeedInvalidate = true);
    void SetVisible(bool bVisible = true) override;
    void SetInternVisible(bool bVisible = true) override;
    SIZE EstimateSize(SIZE szAvailable);
    void DoEvent(TEventUI &event) override;
    void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue) override;

    void PaintStatusImage(HDC hDC);
    void PaintText(HDC hDC);

protected:
    bool OnDoNotify(void *p);
    CEditWnd *m_pWindow;

    UINT m_uMaxChar;
    bool m_bReadOnly;
    bool m_bPasswordMode;
    TCHAR m_cPasswordChar;
    UINT m_uButtonState;
    CDuiString m_sNormalImage;
    CDuiString m_sHotImage;
    CDuiString m_sFocusedImage;
    CDuiString m_sDisabledImage;
    DWORD m_dwTipValueColor;
    DWORD m_dwEditbkColor;
    DWORD m_dwEditTextColor;
    UINT m_iWindowStyls;
};
}
#endif // __UIEDIT_H__